from dataclasses import dataclass


@dataclass
class FaultDetectionConfig:
    """故障检测配置"""
    fs: int  # 采样率
    freq: float = 50.0  # 工频
    current_threshold: float = 0.1  # 电流变化阈值
    voltage_threshold: float = 5.0  # 电压变化阈值
    i_dz: float = 5.0  # 突变检测门槛值
    use_wavelet: bool = True
    wavelet = 'db4'

    # 向后兼容性属性
    @property
    def threshold(self) -> float:
        """向后兼容：返回电流阈值"""
        return self.current_threshold

    @threshold.setter
    def threshold(self, value: float):
        """向后兼容：设置电流和电压阈值"""
        self.current_threshold = value
        self.voltage_threshold = value
